﻿using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

namespace Elifart.Library.Serialization
{
    public static class ObjectWriter
    {
        #region Static Methods

        public static void Save(object value, string filePath)
        {
            Stream stream = File.Open(filePath, FileMode.Create);
            BinaryFormatter binaryFormatter = new BinaryFormatter();
            binaryFormatter.Serialize(stream, value);
            binaryFormatter = null;
            stream.Flush();
            stream.Close();
        }

        #endregion
    }
}
